package cn.myfirefly.moming.house.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.myfirefly.moming.common.controller.BaseCommonController;
import cn.myfirefly.moming.house.model.ReturnVisitCountDto;
import cn.myfirefly.moming.house.model.ReturnVisitCountFilterDto;
import cn.myfirefly.moming.house.service.SpfTradeReturnVisitService;
import cn.myfirefly.core.annotation.BjuiDataGridFilterDtoWrap;
import cn.myfirefly.core.model.PageResultDto;
import cn.myfirefly.core.model.ResultDto;
import cn.myfirefly.utils.ExportUtil;
import cn.myfirefly.utils.StrUtil;

/**
 * 回访汇总统计
 * @author zhouxiaoming
 */
@Controller
@RequestMapping("returnVisitCount")
public class ReturnVisitCountController extends BaseCommonController {

	@Autowired
	private SpfTradeReturnVisitService spfTradeReturnVisitService;
	
	@RequestMapping("index.do")
	public String index(HttpServletRequest request, 
			HttpServletResponse response) {
		return "returnvisitcount/index";
	}
	
	@RequestMapping("list.do")
	@ResponseBody
	@BjuiDataGridFilterDtoWrap
	public PageResultDto<ReturnVisitCountDto> list(ReturnVisitCountFilterDto dto, HttpServletRequest request, 
			HttpServletResponse response) {
		PageResultDto<ReturnVisitCountDto> result = spfTradeReturnVisitService.getReturnVisitCountList(dto);
		return result;
	}
	
	@RequestMapping("export.do")
	@ResponseBody
	@BjuiDataGridFilterDtoWrap
	public ResultDto export(ReturnVisitCountFilterDto dto, HttpServletRequest request, 
			HttpServletResponse response) {
		List<ReturnVisitCountDto> list = spfTradeReturnVisitService.getReturnVisitCountAllList(dto);
		String msg = ExportUtil.export(list, "ReturnVisitCount", "回访汇总统计", request, response);
		if (StrUtil.notBlank(msg)) {
			return error(msg);
		}
		return null;
	}
}
